﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucMonHoc.ascx.cs" Inherits="STT.Admin.UserControls.ucMonHoc" %>

<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">--%>
<%--<ContentTemplate>--%>
<div id="content-header">
    <div id="breadcrumb">
        <a href="../Default.aspx" class="tip-bottom" data-original-title="Về bảng điều khiển">
            <i class="icon-home"></i>Trang chủ
        </a>
       <a href="../Admin/Default.aspx?" class="current">Quản lý khóa-lớp học</a>
        <a href="../Admin/Default.aspx?" class="current">Quản lý môn học</a>
    </div>
</div>

<div class="widget-box">
    <div class="widget-title">
        <span class="icon"><i class="icon-th"></i></span>
        <h5>Danh sách môn học</h5>

        <div id="search">
            <asp:TextBox ID="txtTimKiem" runat="server" placeholder="Nhập từ tìm kiếm..."></asp:TextBox>
            <button class="tip-left" data-original-title="Tìm kiếm">
                <asp:ImageButton ID="btSearch" runat="server" ImageUrl="~/img/icon-search.png" OnClick="btSearch_Click" />
            </button>
        </div>
    </div>

    <div class="widget-content nopadding">
        <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
            <asp:GridView ID="gvMonHoc" runat="server" CssClass="table table-bordered table-hover"
                AutoGenerateColumns="False" DataKeyNames="MaMonHoc"
                OnRowCommand="gvMonHoc_RowCommand"
                EnableViewState="False" OnRowDeleting="gvMonHoc_RowDeleting">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="cbChonTat" runat="server" onclick="cbChonTat(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbChon" runat="server" onclick="cbChon(this);" />
                        </ItemTemplate>
                        <ItemStyle Width="10px" HorizontalAlign="Center"></ItemStyle>
                    </asp:TemplateField>
                    <asp:BoundField DataField="MaMonHoc" HeaderText="Mã môn học"
                        InsertVisible="False" ReadOnly="True" SortExpression="MaMonHoc"
                        ItemStyle-CssClass="span1">
                        <ItemStyle CssClass="span1"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="TenMonHoc" HeaderText="Tên môn học"
                        SortExpression="TenMonHoc" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="SoHocTrinh" HeaderText="Số học trình"
                        SortExpression="SoHocTrinh" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:BoundField DataField="TenNganh" HeaderText="Tên ngành"
                        SortExpression="TenNganh" ItemStyle-CssClass="span2">
                        <ItemStyle CssClass="span2"></ItemStyle>
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Sửa" ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                                Text="Sửa" CommandName="ChonSua" CommandArgument="<%#((GridViewRow)Container).RowIndex%>">
                                <img src="../../img/edit.jpg" alt="Alternate Text" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xóa" ShowHeader="False">
                        <ItemTemplate>
                            <%-- Bắt sự kiện nhấn nút xóa --%>
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa?');">
                                <img src="../../img/delete.jpg" alt="Alternate Text" />
                            </asp:LinkButton>
                        </ItemTemplate>
                        <ItemStyle CssClass="span1" HorizontalAlign="Center" VerticalAlign="Middle" />
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

            <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl">

                <asp:LinkButton ID="lbXoaTat" runat="server" CssClass="btn" OnClientClick="return ConfirmDelete('Có chắc bạn muốn xóa các dòng đã chọn?');"
                    OnClick="lbXoaTat_Click">Xóa chọn</asp:LinkButton>

                <a href="#thongTin" data-toggle="modal" id="btThem">
                    <button class="btn"  id="change">
                        Thêm mới
                    </button>
                </a>
                <asp:HyperLink ID="HyperLink2" CssClass="btn" Target="_blank" runat="server" NavigateUrl="~/Report/ViewMonHoc.aspx">                        
                            Xuất dữ liệu
                </asp:HyperLink>
            </div>
        </div>
    </div>
</div>

<div id="validationcontrol">
    <div id="thongTin" class="modal hide" aria-hidden="true" style="display: none;">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h3 runat="server" id="txtTieuDe" class="username">Thêm môn học</h3>
        </div>
        <div class="modal-body">
            <div class="control-group">
                <label class="control-label">Tên môn học: </label>
                <div class="controls">
                    <asp:TextBox ID="txtTenMonHoc" runat="server" TextMode="SingleLine" class="validate"
                        data-validate="required"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationExpression="^[\s\S]{0,100}$"
                        ToolTip="Bạn chưa nhập sĩ số " ForeColor="Red" Font-Bold="true" ControlToValidate="txtTenMonHoc"
                        runat="server" ErrorMessage="(*)" ValidationGroup="dn"></asp:RequiredFieldValidator>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Số học trình: </label>
                <div class="controls">
                    <asp:TextBox ID="txtSoHocTrinh" runat="server" class="validate"
                        data-validate="required"></asp:TextBox>
                    <asp:CompareValidator ID="cmpBirthDate" Text="(Không đúng kiểu số)" ControlToValidate="txtSoHocTrinh"
                        ValidationGroup="dn" Type="Double" Operator="DataTypeCheck" runat="server" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationExpression="^[\s\S]{0,3}$"
                        ToolTip="Bạn chưa nhập sĩ số " ForeColor="Red" Font-Bold="true" ControlToValidate="txtSoHocTrinh"
                        runat="server" ErrorMessage="(*)" ValidationGroup="dn"></asp:RequiredFieldValidator>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">Tên Ngành : </label>
                <div class="controls">
                    <asp:DropDownList ID="ddNganh" runat="server" class="validate"
                        data-validate="required">
                    </asp:DropDownList>
                    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Admin/Default.aspx?idpage=qlnganh">
                        <img  src="../../img/add.png"/>
                    </asp:HyperLink>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="btThemMoi" runat="server" CssClass="btn btn-primary" Text="Thêm mới"
                OnClick="lbThemMoi_Click" CausesValidation="true"
                ValidationGroup="dn" />
            <asp:Button ID="btSua" runat="server" CssClass="btn btn-primary btValidate" Text="Lưu"
                OnClick="btSua_Click" CausesValidation="true"
                ValidationGroup="dn" />
            <a data-dismiss="modal" class="btn" href="#">Hủy</a>
        </div>
    </div>
</div>

<div id="themFileExcel" class="modal hide" aria-hidden="true" style="display: none;">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">×</button>
        <h3 runat="server" id="H1">Thêm từ file Excel</h3>
    </div>
    <div class="modal-body">
        <asp:FileUpload ID="FileUpload" runat="server" />
    </div>
    <div class="modal-footer">
        <asp:Button ID="btThemExcel" runat="server" CssClass="btn btn-primary" Text="Thêm từ file"
            OnClick="btThemExcel_Click" />
        <a data-dismiss="modal" class="btn" href="#">Hủy</a>
    </div>
</div>

<script>
    $(document).ready(function () {
        $(document).ready(function () {
            $("#change").click(function (event) {
                $('.username').html("Thêm môn học");
            });
        });
    $(document).ready(function () {
        $('.btValidate').click(function () {
            $('form').quickValidate();
        });
        if ('<%Response.Write(chonSuaClick.ToString());%>' == 'True') {
            $('#btThem').click();
            $('#<%=btThemMoi.ClientID%>').css('display', 'none');
                    $('#<%=btSua.ClientID%>').css('display', 'inline-block');
        }

        $('#btThem').click(function () {
            $('#thongTin').find('input:not([type=submit])').val('');
            $('#<%=btThemMoi.ClientID%>').css('display', 'inline-block');
                    $('#<%=btSua.ClientID%>').css('display', 'none');
                });
    });
    });
</script>


<%--</asp:UpdatePanel>--%>
